package cn.edu.sjtu.se.dslab.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.sjtu.se.dslab.component.method.InterfaceMethod;
import cn.edu.sjtu.se.dslab.dao.IInterfaceMethodDao;
import cn.edu.sjtu.se.dslab.service.IInterfaceMethodService;

@Service("interfaceMethodService")
@Transactional
public class InterfaceMethodServiceImpl implements IInterfaceMethodService {

	@Resource(name = "interfaceMethodDao")
	private IInterfaceMethodDao interfaceMethodDao;

	@Override
	public boolean addInterfaceMethod(InterfaceMethod interfaceMethod) {
		// TODO Auto-generated method stub
		interfaceMethodDao.save(interfaceMethod);
		return true;
	}

	@Override
	public InterfaceMethod getInterfaceMethodById(long id) {
		// TODO Auto-generated method stub
		InterfaceMethod method = interfaceMethodDao.queryById(id);
		return method;
	}

	@Override
	public boolean updateInterfaceMethod(InterfaceMethod interfaceMethod) {
		// TODO Auto-generated method stub
		interfaceMethodDao.update(interfaceMethod);
		return true;
	}

	@Override
	public List<InterfaceMethod> getAllInterfaceMethod() {
		// TODO Auto-generated method stub
		return interfaceMethodDao.queryWithInterfaceNotNull();
	}

	@Override
	public boolean deleteInterfaceMethodById(long id) {
		// TODO Auto-generated method stub
		return interfaceMethodDao.deleteById(id);
	}

	@Override
	public boolean deleteInterfaceMethod(InterfaceMethod interfaceMethod) {
		// TODO Auto-generated method stub
		return interfaceMethodDao.delete(interfaceMethod);
	}

}
